Skip to content

Conversation

@baominghelly
Copy link

@baominghelly baominghelly commented Nov 27, 2025

Description

Add test execution gateway for dynamic input operator test.

Tests

Test json file example(inplace out = A)

{
    "operator": "mul",
    "device": "cuda",
    "description": "Mul - INPLACE(a) (Complex Strides)",
    
    "torch_op": "torch.mul",
    "infinicore_op": "infinicore.mul",

    "tolerance": {
        "atol": 1e-5,
        "rtol": 1e-3
    },
    "args": {
        "bench": "both",
        "num_prerun": 10,
        "num_iterations": 100,
        "verbose": false
    },
    "inputs": [
        {
            "name": "a",
            "dtype": "float32",
            "shape": [13, 4, 4],
            "strides": [20, 4, 1]
        },
        {
            "name": "b",
            "dtype": "float32",
            "shape": [13, 4, 4],
            "strides": [20, 4, 1]
        }
    ],
    "output_spec": null,
    "kwargs": {
        "out": 0
    },
    "comparison_target": 0
}

Test evidence

Out of place

(py3.13) libaoming@LAPTOP-4206MIBQ:~/workplace/InfiniCore$ python test/infinicore/framework/test_gateway.py test/infinicore/framework/mul1.json --device cpu --n
um_prerun 20 --num_iterations 200
🚀 Gateway: Start processing...
📄 Source: Loading test/infinicore/framework/mul1.json
⚙️  Ready to execute operator: 'mul'
    Targets: Torch -> torch.mul
             Infini -> infinicore.mul
    Target Devices: CPU
    Config: Bench=both, Prerun=20, Iterations=200
    Description: Mul - OUT_OF_PLACE (Complex Strides)

============================================================
Testing mul on CPU
============================================================
TestCase(Mul - OUT_OF_PLACE (Complex Strides) - inputs=[a: tensor(13, 4, 4), strides=(20, 4, 1), float32; b: tensor(13, 4, 4), strides=(20, 4, 1), float32])
    PyTorch    time - Host: 0.003349 ms, Device: 0.000000 ms
    InfiniCore time - Host: 0.210795 ms, Device: 0.000000 ms
✓ Passed

============================================================
TEST SUMMARY
Total tests: 1
Passed: 1
Success rate: 100.0%

All tests passed!
------------------------------------------------------------
BENCHMARK SUMMARY
PyTorch Host Total Time: 0.670 ms
InfiniCore Host Total Time: 42.159 ms
Host Speedup (PyTorch/InfiniCore): 0.02x
============================================================
🏁 Gateway: Process finished.

Inplace C

(py3.13) libaoming@LAPTOP-4206MIBQ:~/workplace/InfiniCore$ python test/infinicore/framework/test_gateway.py test/infinicore/framework/mul2.json --device cpu --n
um_prerun 20 --num_iterations 200
🚀 Gateway: Start processing...
📄 Source: Loading test/infinicore/framework/mul2.json
⚙️  Ready to execute operator: 'mul'
    Targets: Torch -> torch.mul
             Infini -> infinicore.mul
    Target Devices: CPU
    Config: Bench=both, Prerun=20, Iterations=200
    Description: Mul - INPLACE(out) (Complex Strides)

============================================================
Testing mul on CPU
============================================================
TestCase(Mul - INPLACE(out) (Complex Strides) - inputs=[a: tensor(13, 4, 4), strides=(20, 4, 1), float32; b: tensor(13, 4, 4), strides=(20, 4, 1), float32], kwargs={out=c: tensor(13, 4, 4), strides=(20, 4, 1), float32})
    PyTorch    time - Host: 0.002892 ms, Device: 0.000000 ms
    InfiniCore time - Host: 0.009530 ms, Device: 0.000000 ms
✓ Passed

============================================================
TEST SUMMARY
Total tests: 1
Passed: 1
Success rate: 100.0%

All tests passed!
------------------------------------------------------------
BENCHMARK SUMMARY
PyTorch Host Total Time: 0.578 ms
InfiniCore Host Total Time: 1.906 ms
Host Speedup (PyTorch/InfiniCore): 0.30x
============================================================
🏁 Gateway: Process finished.

Inplace A

(py3.13) libaoming@LAPTOP-4206MIBQ:~/workplace/InfiniCore$ python test/infinicore/framework/test_gateway.py test/infinicore/framework/mul3.json --device cpu --n
um_prerun 20 --num_iterations 200
🚀 Gateway: Start processing...
📄 Source: Loading test/infinicore/framework/mul3.json
⚙️  Ready to execute operator: 'mul'
    Targets: Torch -> torch.mul
             Infini -> infinicore.mul
    Target Devices: CPU
    Config: Bench=both, Prerun=20, Iterations=200
    Description: Mul - INPLACE(a) (Complex Strides)

============================================================
Testing mul on CPU
============================================================
TestCase(Mul - INPLACE(a) (Complex Strides) - inputs=[a: tensor(13, 4, 4), strides=(20, 4, 1), float32; b: tensor(13, 4, 4), strides=(20, 4, 1), float32], kwargs={out=a})
    PyTorch    time - Host: 0.002911 ms, Device: 0.000000 ms
    InfiniCore time - Host: 0.006440 ms, Device: 0.000000 ms
✓ Passed

============================================================
TEST SUMMARY
Total tests: 1
Passed: 1
Success rate: 100.0%

All tests passed!
------------------------------------------------------------
BENCHMARK SUMMARY
PyTorch Host Total Time: 0.582 ms
InfiniCore Host Total Time: 1.288 ms
Host Speedup (PyTorch/InfiniCore): 0.45x
============================================================
🏁 Gateway: Process finished.

Inplace B

(py3.13) libaoming@LAPTOP-4206MIBQ:~/workplace/InfiniCore$ python test/infinicore/framework/test_gateway.py test/infinicore/framework/mul4.json --device cpu --n
um_prerun 20 --num_iterations 200
🚀 Gateway: Start processing...
📄 Source: Loading test/infinicore/framework/mul4.json
⚙️  Ready to execute operator: 'mul'
    Targets: Torch -> torch.mul
             Infini -> infinicore.mul
    Target Devices: CPU
    Config: Bench=both, Prerun=20, Iterations=200
    Description: Mul - INPLACE(b) (Complex Strides)

============================================================
Testing mul on CPU
============================================================
TestCase(Mul - INPLACE(b) (Complex Strides) - inputs=[a: tensor(13, 4, 4), strides=(20, 4, 1), float32; b: tensor(13, 4, 4), strides=(20, 4, 1), float32], kwargs={out=b})
    PyTorch    time - Host: 0.004103 ms, Device: 0.000000 ms
    InfiniCore time - Host: 0.008236 ms, Device: 0.000000 ms
✓ Passed

============================================================
TEST SUMMARY
Total tests: 1
Passed: 1
Success rate: 100.0%

All tests passed!
------------------------------------------------------------
BENCHMARK SUMMARY
PyTorch Host Total Time: 0.821 ms
InfiniCore Host Total Time: 1.647 ms
Host Speedup (PyTorch/InfiniCore): 0.50x
============================================================
🏁 Gateway: Process finished.

@baominghelly baominghelly self-assigned this Nov 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants