def check(self, outputs, check_shape=False):
    cpu_fp32 = outputs[ExecutionMode.CPU_FP32]
    ipu_fp32 = outputs[ExecutionMode.IPU_FP32]
    max_diff = np.abs((cpu_fp32 - ipu_fp32)).max()
    fp32_flag = np.allclose(cpu_fp32, ipu_fp32, rtol=self.rtol, atol=self.atol)
    self.assertTrue(fp32_flag, ('max diff is %f' % max_diff))
    if check_shape:
        self.assertTrue((cpu_fp32.shape == ipu_fp32.shape))
    ipu_popart_fp16 = None
    if (ExecutionMode.IPU_POPART_FP16 in outputs.keys()):
        ipu_popart_fp16 = outputs[ExecutionMode.IPU_POPART_FP16]
        max_diff = np.abs((ipu_popart_fp16.astype(np.float32) - cpu_fp32)).max()
        fp16_flag = np.allclose(ipu_popart_fp16.astype(np.float32), cpu_fp32, rtol=self.rtol_fp16, atol=self.atol_fp16)
        self.assertTrue(fp16_flag, ('max diff is %f' % max_diff))
        if check_shape:
            self.assertTrue((ipu_popart_fp16.shape == cpu_fp32.shape))
def check(self, outputs, check_shape=False):
    cpu_fp32 = outputs[ExecutionMode.CPU_FP32]
    ipu_fp32 = outputs[ExecutionMode.IPU_FP32]
    max_diff = np.abs((cpu_fp32 - ipu_fp32)).max()
    fp32_flag = np.allclose(cpu_fp32, ipu_fp32, rtol=self.rtol, atol=self.atol)
    self.assertTrue(fp32_flag, ('max diff is %f' % max_diff))
    if check_shape:
        self.assertTrue((cpu_fp32.shape == ipu_fp32.shape))
    ipu_popart_fp16 = None
    if (ExecutionMode.IPU_POPART_FP16 in outputs.keys()):
        ipu_popart_fp16 = outputs[ExecutionMode.IPU_POPART_FP16]
        max_diff = np.abs((ipu_popart_fp16.astype(np.float32) - cpu_fp32)).max()
        fp16_flag = np.allclose(ipu_popart_fp16.astype(np.float32), cpu_fp32, rtol=self.rtol_fp16, atol=self.atol_fp16)
        self.assertTrue(fp16_flag, ('max diff is %f' % max_diff))
        if check_shape:
            self.assertTrue((ipu_popart_fp16.shape == cpu_fp32.shape))