forked from EngineX-Cambricon/enginex-mlu370-vllm
add ops
This commit is contained in:
26
torch_mlu_ops-v1.3.2/tools/diff.py
Executable file
26
torch_mlu_ops-v1.3.2/tools/diff.py
Executable file
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import numpy as np
|
||||
import sys
|
||||
|
||||
|
||||
def check(x: np.ndarray, y: np.ndarray) -> tuple:
|
||||
error = np.abs(x - y)
|
||||
diff1 = np.sum(error)/np.sum(np.abs(x))
|
||||
diff2 = np.sqrt(np.sum(error**2)/np.sum(x**2))
|
||||
|
||||
max = np.max(error)
|
||||
mean = np.mean(error)
|
||||
return diff1, diff2, max, mean
|
||||
|
||||
if "__main__" == __name__:
|
||||
# read command line arguments
|
||||
x = np.loadtxt(sys.argv[1])
|
||||
y = np.loadtxt(sys.argv[2])
|
||||
# compute mean squared error
|
||||
diff1, diff2, max, mean = check(x, y)
|
||||
|
||||
print("diff1: ", diff1)
|
||||
print("diff2: ", diff2)
|
||||
print("max error: ", max)
|
||||
print("mean error: ", mean)
|
||||
Reference in New Issue
Block a user