-
Notifications
You must be signed in to change notification settings - Fork 137
Expand file tree
/
Copy pathtest-gnn-remaining-functions.cjs
More file actions
126 lines (107 loc) · 4.46 KB
/
test-gnn-remaining-functions.cjs
File metadata and controls
126 lines (107 loc) · 4.46 KB
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
/**
* Test Remaining GNN Functions
* Verify which GNN functions work and which are broken
*/
const gnn = require('@ruvector/gnn');
async function testRemainingFunctions() {
console.log('\n🔬 Testing Remaining GNN Functions\n');
console.log('=' .repeat(60));
// Test 1: hierarchicalForward
console.log('📝 Test 1: hierarchicalForward');
try {
const input = new Float32Array(128).map(() => Math.random());
const weights = new Float32Array(128 * 64).map(() => Math.random());
const result = gnn.hierarchicalForward(input, weights, 128, 64);
console.log(' ✅ SUCCESS: hierarchicalForward works');
console.log(` Output type: ${result.constructor.name}`);
console.log(` Output length: ${result.length}`);
} catch (error) {
console.log(` ❌ FAILED: ${error.message}`);
}
// Test 2: hierarchicalForward with different signatures
console.log('\n📝 Test 2: hierarchicalForward (alt signature)');
try {
const input = new Float32Array(128).map(() => Math.random());
const weights1 = new Float32Array(128 * 64).map(() => Math.random());
const weights2 = new Float32Array(64 * 32).map(() => Math.random());
const result = gnn.hierarchicalForward(input, [weights1, weights2]);
console.log(' ✅ SUCCESS: hierarchicalForward with array of weights');
console.log(` Output length: ${result.length}`);
} catch (error) {
console.log(` ❌ FAILED: ${error.message}`);
}
// Test 3: RuvectorLayer constructor
console.log('\n📝 Test 3: RuvectorLayer constructor');
try {
// Try different constructor signatures
const layer1 = new gnn.RuvectorLayer(128, 64);
console.log(' ✅ SUCCESS: RuvectorLayer(inputDim, outputDim)');
} catch (error) {
console.log(` ❌ FAILED (2 args): ${error.message}`);
try {
const layer2 = new gnn.RuvectorLayer({ inputDim: 128, outputDim: 64 });
console.log(' ✅ SUCCESS: RuvectorLayer({inputDim, outputDim})');
} catch (error2) {
console.log(` ❌ FAILED (config obj): ${error2.message}`);
try {
const layer3 = new gnn.RuvectorLayer(128, 64, 'relu');
console.log(' ✅ SUCCESS: RuvectorLayer(input, output, activation)');
} catch (error3) {
console.log(` ❌ FAILED (3 args): ${error3.message}`);
}
}
}
// Test 4: TensorCompress constructor
console.log('\n📝 Test 4: TensorCompress constructor');
try {
// Try different compression levels
const compress1 = new gnn.TensorCompress('half');
console.log(' ✅ SUCCESS: TensorCompress("half")');
} catch (error) {
console.log(` ❌ FAILED (string): ${error.message}`);
try {
const compress2 = new gnn.TensorCompress({ levelType: 'half' });
console.log(' ✅ SUCCESS: TensorCompress({levelType: "half"})');
} catch (error2) {
console.log(` ❌ FAILED (config obj): ${error2.message}`);
try {
const compress3 = new gnn.TensorCompress({ levelType: 'half', scale: 1.0 });
console.log(' ✅ SUCCESS: TensorCompress({levelType, scale})');
} catch (error3) {
console.log(` ❌ FAILED (full config): ${error3.message}`);
}
}
}
// Test 5: getCompressionLevel
console.log('\n📝 Test 5: getCompressionLevel');
try {
const levels = ['none', 'half', 'pq8', 'pq4', 'binary'];
for (const level of levels) {
try {
const config = gnn.getCompressionLevel(level);
console.log(` ✅ SUCCESS: getCompressionLevel("${level}")`);
console.log(` Config: ${JSON.stringify(config)}`);
} catch (error) {
console.log(` ❌ FAILED ("${level}"): ${error.message}`);
}
}
} catch (error) {
console.log(` ❌ FAILED: ${error.message}`);
}
// Test 6: Check type definitions
console.log('\n📝 Test 6: Exported Types and Functions');
console.log(` Exports: ${Object.keys(gnn).join(', ')}`);
for (const key of Object.keys(gnn)) {
console.log(` - ${key}: ${typeof gnn[key]}`);
}
console.log('\n📊 Summary:');
console.log('=' .repeat(60));
console.log(' differentiableSearch: ✅ Working (Float32Array required)');
console.log(' hierarchicalForward: Testing above...');
console.log(' RuvectorLayer: Testing above...');
console.log(' TensorCompress: Testing above...');
console.log(' getCompressionLevel: Testing above...');
console.log('\n' + '=' .repeat(60));
console.log('🎉 GNN Function Testing Complete!\n');
}
testRemainingFunctions().catch(console.error);