catniff 0.9.1 → 0.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core.d.ts +1 -0
- package/dist/core.js +6 -0
- package/dist/dtype.js +6 -1
- package/package.json +1 -1
package/dist/core.d.ts
CHANGED
|
@@ -221,6 +221,7 @@ export declare class Tensor {
|
|
|
221
221
|
matmul(other: TensorValue | Tensor): Tensor;
|
|
222
222
|
tensordot(other: TensorValue | Tensor, axes?: number | [number, number] | [number[], number[]]): Tensor;
|
|
223
223
|
conv2d(weight: Tensor | TensorValue, bias?: Tensor | TensorValue, stride?: number | [number, number], padding?: number | [number, number], dilation?: number | [number, number], groups?: number): Tensor;
|
|
224
|
+
where(x: Tensor | TensorValue, y: Tensor | TensorValue): Tensor;
|
|
224
225
|
dropout(rate: number): Tensor;
|
|
225
226
|
triu(diagonal?: number): Tensor;
|
|
226
227
|
tril(diagonal?: number): Tensor;
|
package/dist/core.js
CHANGED
|
@@ -2250,6 +2250,12 @@ class Tensor {
|
|
|
2250
2250
|
}
|
|
2251
2251
|
return out;
|
|
2252
2252
|
}
|
|
2253
|
+
// Conditionally select elements from x and y
|
|
2254
|
+
where(x, y) {
|
|
2255
|
+
x = this.handleOther(x);
|
|
2256
|
+
y = this.handleOther(y);
|
|
2257
|
+
return this.mul(x).add(this.neg().add(1).mul(y));
|
|
2258
|
+
}
|
|
2253
2259
|
// Dropout
|
|
2254
2260
|
dropout(rate) {
|
|
2255
2261
|
if (!Tensor.training || rate === 0)
|
package/dist/dtype.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TypedArray = exports.dtypeHiearchy = void 0;
|
|
4
|
+
// Compatibility check
|
|
5
|
+
const float16Supported = typeof Float16Array !== "undefined";
|
|
6
|
+
if (!float16Supported) {
|
|
7
|
+
console.log("Warning: Your JS runtime does not support Float16Array, falling back to Float32Array...");
|
|
8
|
+
}
|
|
4
9
|
exports.dtypeHiearchy = {
|
|
5
10
|
"float64": 8,
|
|
6
11
|
"float32": 7,
|
|
@@ -15,7 +20,7 @@ exports.dtypeHiearchy = {
|
|
|
15
20
|
exports.TypedArray = {
|
|
16
21
|
"float64": Float64Array,
|
|
17
22
|
"float32": Float32Array,
|
|
18
|
-
"float16": Float16Array,
|
|
23
|
+
"float16": float16Supported ? Float16Array : Float32Array,
|
|
19
24
|
"int32": Int32Array,
|
|
20
25
|
"int16": Int16Array,
|
|
21
26
|
"int8": Int8Array,
|