MCPcopy Create free account
hub / github.com/apache/singa / l2

Method l2

src/core/tensor/tensor.cc:833–843  ·  view source on GitHub ↗

L2 norm, Do not use Nrm2 (name conflict).

Source from the content-addressed store, hash-verified

831
832/// L2 norm, Do not use Nrm2 (name conflict).
833float Tensor::l2() const {
834 float nrm = 0.0f;
835 TYPE_LANG_SWITCH(data_type_, DType, device_->lang(), Lang, {
836 device_->Exec(
837 [&nrm, this](Context *ctx) {
838 Nrm2<DType, Lang>(*this, &nrm, ctx);
839 },
840 {this->block()}, {}, "L1");
841 });
842 return nrm / Size();
843}
844
845// DEPRECATED use l2()
846float Tensor::L2() const { return l2(); }

Callers 1

forwardMethod · 0.45

Calls 3

blockMethod · 0.95
langMethod · 0.80
ExecMethod · 0.80

Tested by 1

forwardMethod · 0.36