{
  "id": "fn-gpu-subtract",
  "dataComponent": "gpu",
  "heading": {
    "title": "subtract",
    "badges": ["GPU", "PARTIAL"]
  },
  "synopsis": "Elementwise subtraction of two tensors on the GPU (A - B). Returns a new tensor with the same shape, or errors on mismatch.",
  "codeBlocks": [
    "extend(\"gpu\")\\n\\n# 1) Provide two equally sized 2D tensors:\\nA = gpu:to_tensor([[10,12],[3,8]])\\nB = gpu:to_tensor([[1,2],[3,4]])\\nC = gpu:subtract(A, B)\\nslog(gpu:to_array(C))\\n# => [[9.0,10.0],[0.0,4.0]]\\n\\n# 2) Partial usage => known A, missing B\\nsubA = gpu:subtract(A)\\nres = subA(B)\\nslog(gpu:to_array(res))\\n# => [[9.0,10.0],[0.0,4.0]]\\n\\n# 3) If shapes differ, bridging raises an error or logs fallback.\\n# 4) CPU fallback => if GPU not available.\\n"
  ],
  "notes": [
    "gpu:subtract(A, B) => A[i][j] - B[i][j], shapes must match exactly.",
    "Partial usage => pass one argument now, the second later. E.g. gpu:subtract(A) => function expecting B.",
    "If bridging is incomplete or GPU is unavailable, logs fallback CPU path but still returns the correct result."
  ]
}
