| 824 | } |
| 825 | |
| 826 | static Result<std::unique_ptr<KernelState>> Init(KernelContext* ctx, |
| 827 | const KernelInitArgs& args) { |
| 828 | if (!args.options) { |
| 829 | return Status::Invalid("Must provide IndexOptions for index kernel"); |
| 830 | } |
| 831 | const auto& options = static_cast<const IndexOptions&>(*args.options); |
| 832 | if (!options.value) { |
| 833 | return Status::Invalid("Must provide IndexOptions.value for index kernel"); |
| 834 | } else if (!options.value->type->Equals(*args.inputs[0].type)) { |
| 835 | return Status::TypeError("Expected IndexOptions.value to be of type ", |
| 836 | *args.inputs[0].type, ", but got ", *options.value->type); |
| 837 | } |
| 838 | IndexInit visitor(ctx, options, *args.inputs[0].type); |
| 839 | return visitor.Create(); |
| 840 | } |
| 841 | }; |
| 842 | |
| 843 | } // namespace |