{
  "id": "fn-gpu-hadamard",
  "dataComponent": "gpu",
  "heading": {
    "title": "hadamard",
    "badges": ["GPU", "PARTIAL"]
  },
  "synopsis": "Elementwise (Hadamard) multiplication of two tensors on the GPU. Both must have the same shape. Partial usage is possible.",
  "codeBlocks": [
    "extend(\"gpu\")\\n\\n# 1) Basic hadamard => elementwise multiply\\nA = gpu:to_tensor([[1,2],[3,4]])\\nB = gpu:to_tensor([[10,10],[2,2]])\\nC = gpu:hadamard(A, B)\\nslog(gpu:to_array(C))\\n# => [[10.0,20.0],[6.0,8.0]]\\n\\n# 2) Partial usage => known B, missing A\\nhadB = gpu:hadamard(_, B)\\nres = hadB(A)\\nslog(gpu:to_array(res))\\n# => [[10.0,20.0],[6.0,8.0]]\\n\\n# 3) If shapes mismatch => bridging error.\\n# 4) If GPU path not implemented => logs fallback CPU.\\n"
  ],
  "notes": [
    "gpu:hadamard => A[i] * B[i] for each element. Both tensors must share the same shape.",
    "If dimension mismatch, bridging raises an error. If GPU is unavailable, CPU fallback occurs.",
    "Partial usage => pass just A or B first. E.g. hadX = gpu:hadamard(A), then hadX(B)."
  ]
}
