UNPKG

2.46 kBSource Map (JSON)View Raw
1{"version":3,"file":"ones.js","sourceRoot":"","sources":["../../src/ops/ones.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAC,MAAM,EAAC,MAAM,WAAW,CAAC;AAGjC,OAAO,EAAC,kBAAkB,EAAE,aAAa,EAAC,MAAM,SAAS,CAAC;AAE1D,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAClC,OAAO,EAAC,KAAK,EAAC,MAAM,SAAS,CAAC;AAE9B;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,IAAI,CAChB,KAAkB,EAAE,QAAkB,SAAS;IACjD,IAAI,KAAK,KAAK,WAAW,EAAE;QACzB,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;QACpC,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;QACrC,OAAO,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;KAC5B;IACD,MAAM,MAAM,GAAG,kBAAkB,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,CAAC;IAC/D,OAAO,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,CAAc,CAAC;AAC9D,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2018 Google LLC. All Rights Reserved.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n * =============================================================================\n */\n\nimport {ENGINE} from '../engine';\nimport {Tensor} from '../tensor';\nimport {DataType, Rank, ShapeMap} from '../types';\nimport {makeOnesTypedArray, sizeFromShape} from '../util';\n\nimport {complex} from './complex';\nimport {zeros} from './zeros';\n\n/**\n * Creates a `tf.Tensor` with all elements set to 1.\n *\n * ```js\n * tf.ones([2, 2]).print();\n * ```\n *\n * @param shape An array of integers defining the output tensor shape.\n * @param dtype The type of an element in the resulting tensor. Defaults to\n * 'float'.\n *\n * @doc {heading: 'Tensors', subheading: 'Creation'}\n */\nexport function ones<R extends Rank>(\n shape: ShapeMap[R], dtype: DataType = 'float32'): Tensor<R> {\n if (dtype === 'complex64') {\n const real = ones(shape, 'float32');\n const imag = zeros(shape, 'float32');\n return complex(real, imag);\n }\n const values = makeOnesTypedArray(sizeFromShape(shape), dtype);\n return ENGINE.makeTensor(values, shape, dtype) as Tensor<R>;\n}\n"]}
\No newline at end of file