Return `a-b`, where x is CTensor.
(self, a, b)
| 3005 | super(Sub, self).__init__() |
| 3006 | |
| 3007 | def forward(self, a, b): |
| 3008 | """ |
| 3009 | Return `a-b`, where x is CTensor. |
| 3010 | """ |
| 3011 | ori_type = None |
| 3012 | if a.data_type() != singa.kFloat32: |
| 3013 | ori_type = a.data_type() |
| 3014 | a = a.AsType(singa.kFloat32) |
| 3015 | b = b.AsType(singa.kFloat32) |
| 3016 | res = singa.__sub__(a, b) |
| 3017 | if ori_type is not None: |
| 3018 | res = res.AsType(ori_type) |
| 3019 | if training: |
| 3020 | self.shape0 = list(a.shape()) |
| 3021 | self.shape1 = list(b.shape()) |
| 3022 | self.shape3 = list(res.shape()) |
| 3023 | return res |
| 3024 | |
| 3025 | def backward(self, dy): |
| 3026 | """ |