{"record":{"id":"7d64b06968ec9b04","repo":"Unity-Technologies/ml-agents","slug":"only-float-data-types-are-currently-supported","errorCode":null,"errorMessage":"Only float data types are currently supported","messagePattern":"Only float data types are currently supported","errorType":"exception","errorClass":"NotImplementedException","httpStatus":null,"severity":"error","filePath":"com.unity.ml-agents/Runtime/Inference/TensorProxy.cs","lineNumber":189,"sourceCode":"        }\n\n        /// <summary>\n        /// Fill a pre-allocated Tensor with random numbers\n        /// </summary>\n        /// <param name=\"tensorProxy\">The pre-allocated Tensor to fill</param>\n        /// <param name=\"randomNormal\">RandomNormal object used to populate tensor</param>\n        /// <exception cref=\"NotImplementedException\">\n        /// Throws when trying to fill a Tensor of type other than float\n        /// </exception>\n        /// <exception cref=\"ArgumentNullException\">\n        /// Throws when the Tensor is not allocated\n        /// </exception>\n        public static void FillTensorWithRandomNormal(\n            TensorProxy tensorProxy, RandomNormal randomNormal)\n        {\n            if (tensorProxy.DataType != typeof(float))\n            {\n                throw new NotImplementedException(\"Only float data types are currently supported\");\n            }\n\n            if (tensorProxy.data == null)\n            {\n                throw new ArgumentNullException();\n            }\n\n            tensorProxy.data.CompleteAllPendingOperations();\n\n            for (var i = 0; i < tensorProxy.data.Length(); i++)\n            {\n                ((Tensor<float>)tensorProxy.data)[i] = (float)randomNormal.NextDouble();\n            }\n        }\n    }\n}\n","sourceCodeStart":171,"sourceCodeEnd":206,"githubUrl":"https://github.com/Unity-Technologies/ml-agents/blob/3ecb446f75d1e7400eb404c562dc005d3164cffc/com.unity.ml-agents/Runtime/Inference/TensorProxy.cs#L171-L206","documentation":"FillTensorWithRandomNormal only supports float tensors; it throws NotImplementedException if the TensorProxy's DataType is anything else. Random-normal filling (used to generate random inputs, e.g. for testing) has no implementation for other dtypes.","triggerScenarios":"Calling TensorProxy.FillTensorWithRandomNormal with a tensorProxy whose DataType is not typeof(float) (e.g. int, double).","commonSituations":"Custom inference/utility code building non-float tensors and reusing the random-fill helper; test-generation code for quantized or integer-input models.","solutions":["Ensure the TensorProxy.DataType is typeof(float) before calling FillTensorWithRandomNormal","Write a custom fill routine for non-float dtypes","Convert the tensor data to float before filling"],"exampleFix":"// before\nvar proxy = new TensorProxy { DataType = typeof(int), shape = ... };\nTensorUtils.FillTensorWithRandomNormal(proxy, randomNormal);\n// after\nvar proxy = new TensorProxy { DataType = typeof(float), data = new TensorFloat(...) };\nTensorUtils.FillTensorWithRandomNormal(proxy, randomNormal);","handlingStrategy":"type-guard","validationCode":"if (tensorProxy.DataType != typeof(float))\n    throw new InvalidOperationException(\"FillTensorWithRandomNormal requires a float tensor\");","typeGuard":"bool IsFloatTensor(TensorProxy t) => t.DataType == typeof(float);","tryCatchPattern":"try { TensorProxy.FillTensorWithRandomNormal(proxy, randomNormal); }\ncatch (NotImplementedException)\n{ /* fall back to a custom dtype-specific fill routine */ }","preventionTips":["Always create TensorProxy instances with DataType = typeof(float) for random fill helpers","Write dedicated fill helpers for int/other dtypes","Check DataType before invoking shared tensor utilities"],"tags":["unity","ml-agents","tensor","dtype","not-implemented"],"backgroundTag":"unsupported-tensor-dtype","analyzedSha":"3ecb446f75d1e7400eb404c562dc005d3164cffc","analyzedAt":"2026-09-02T16:33:12.832Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T21:17:11.164Z"}