Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
90 lines (78 loc) · 2.17 KB

File metadata and controls

90 lines (78 loc) · 2.17 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
'use strict';
const UtilsCore = require("./utils-core");
/**
* This is a minimalistic version of GPU.js used
* to run precompiled GPU.JS code.
*
* This intentionally excludes the JS AST compiller : which is 400kb alone/
*
* @class GPUCore
*/
module.exports = class GPUCore {
/**
* @name validateKernelObj
* @function
* @static
* @memberOf GPUCore
*
* @description Validates the KernelObj to comply with the defined format
* Note that this does only a limited sanity check, and does not
* guarantee a full working validation.
*
* For the kernel object format see : <kernelObj-format>
*
* @param {Object|String} kernelObj - KernelObj used to validate
*
* @returns {Object} The validated kernel object, converted from JSON if needed
*
*/
static validateKernelObj(kernelObj) {
// NULL validation
if (kernelObj === null) {
throw "KernelObj being validated is NULL";
}
// String JSON conversion
if (typeof kernelObj === "string") {
try {
kernelObj = JSON.parse(kernelObj);
} catch (e) {
console.error(e);
throw "Failed to convert KernelObj from JSON string";
}
// NULL validation
if (kernelObj === null) {
throw "Invalid (NULL) KernelObj JSON string representation";
}
}
// Check for kernel obj flag
if (kernelObj.isKernelObj !== true) {
throw "Failed missing isKernelObj flag check";
}
// Return the validated kernelObj
return kernelObj;
}
/**
* @name loadKernelObj
* @function
* @static
* @memberOf GPUCore
*
* @description Loads the precompiled kernel object. For GPUCore this is the ONLY way to create the kernel.
* To generate the kernelObj use <Kernel.exportKernelObj>
*
* Note that this function calls <validateKernelObj> internally, and throws an exception if it fails.
*
* @see GPUCore.validateKernelObj
* @see Kernel.exportKernelObj
*
* @param {Object} kernelObj - The precompiled kernel object
* @param {Object} inOpt - [Optional] the option overrides to use
*
* @returns {Function} The kernel function
*
*/
static loadKernelObj(kernelObj, inOpt) {
// Validates the kernelObj, throws an exception if it fails
kernelObj = validateKernelObj(kernelObj);
}
};
Morty Proxy This is a proxified and sanitized view of the page, visit original site.